#include "MenuButtonView.h"

const char* DEFAULT_IMAGE_PATH2 = "../images/startButton.png";

MenuButtonView::MenuButtonView()
{
	image=NULL;
	
}

bool  MenuButtonView::loadMedia(void) {
	//Loading success flag
	bool success = true;

	// Carga el mapa de bits por defecto
	this->image = loadTexture(DEFAULT_IMAGE_PATH2);
	if (image == NULL)
	{
		Log::getInstance()->write(Log::ERROR, SDL_GetError());
		success = false;
	}

	this->update();

	return success;
}

void MenuButtonView::close(void) {
	// Destruye la imagen
	SDL_DestroyTexture(image);
	image = NULL;
}

void MenuButtonView::update() {
	// Limpia la pantalla
	SDL_RenderClear(getRenderer());

	// Dibuja la textura sobre la pantalla
	SDL_RenderCopy(getRenderer(), getImage(), NULL, NULL);

	// Actualiza la pantalla
	SDL_RenderPresent(getRenderer());

}

SDL_Texture* MenuButtonView::getImage() {
	return this->image;
}

void MenuButtonView::setImage(SDL_Texture* image){
	this->image = image;
}


MenuButtonView::~MenuButtonView()
{
	close();
}
